import VueRouter from 'vue-router'
import Vue from 'vue'
Vue.use(VueRouter)
const routes = [
    {
        path: '/',
        component: () => import('@/views/Login.vue'),
        // redirect: Login
    }, {
        path: '/UserHome',
        component: () => import('@/views/UserHome.vue'),
        children: [{
            path: '/UserHome/',
            component: () => import('@/components/User/UserMain.vue')
        },
        ]
    },
    {
        path: '/ShowGoods/:goodsId',
        component: () => import('@/components/User/Goods/ShowGoods.vue')
    }, {
        path: '/cart',
        component: () => import('@/components/User/shop/buy/cart.vue')
    },
    {
        path: '/Goods',
        component: () => import('@/components/User/Goods/Goods.vue')
    }, {
        path: '/order/Order',
        component: () => import('@/components/User/order/Order.vue')
    }, {
        path: '/addressAddressDetail',
        component: () => import('@/components/User/address/addressAddressDetail.vue')
    },
    {
        path: '/order/OrderDetail/:id',
        component: () => import('@/components/User/order/Orderdetail.vue')
    },
    {
        path: '/UserDetail',
        component: () => import('@/components/User/UserDetail.vue')
    },
    {
        path: '/coupon',
        component: () => import('@/components/User/coupon/getcoupon.vue')
    },
    {
        path: '/Mycoupon',
        component: () => import('@/components/User/coupon/Mycoupon.vue')
    },
    {
        path: '/home',
        component: () => import('@/views/Home.vue'),
        children: [{
            path: '/home/order',
            component: () => import('@/components/Manager/Order/Order.vue')
        },
        {
            path: '/home/addGoods',
            component: () => import('@/components/Manager/Store/Goods/addGoods.vue')
        }, {
            path: '/home/UPGoods/:goodsId',
            component: () => import('@/components/Manager/Store/Goods/UPGoods.vue')
        }, {
            path: '/home/Personal_Central',
            component: () => import('@/components/Manager/Personal_Central.vue')
        }, {
            path: '/home/Goods/:storeId',  // 添加冒号
            component: () => import('@/components/Manager/Store/Goods/Goods.vue')
        }, {
            path: '/home/User',
            component: () => import('@/components/Manager/User/User.vue')
        }, {
            path: '/home/addUser',
            name: 'addUser',
            component: () => import('@/components/Manager/User/addUser.vue')
        }, {
            path: '/home/UpUser/:id',
            name: 'UpUser',
            component: () => import('@/components/Manager/User/UpUser.vue')
        },

        {
            path: '/home/admin/employeeGoods',
            component: () => import('@/components/Manager/User/UserGoods.vue')
        },
        {
            path: '/home/store',
            component: () => import('@/components/Manager/Store/store.vue')
        },
        {
            path: '/home/',
            component: () => import('@/components/Manager/firstPage/index.vue')
        },
        {
            path: '/home/store/AddStore',
            component: () => import('@/components/Manager/Store/AddStore.vue')
        },
        {
            path: '/home/store/addCommodity',
            component: () => import('@/components/Manager/Commodity/addCommodity.vue')
        },
        {
            path: '/home/sms/brand/index',
            component: () => import('@/components/Manager/sms/brand/index.vue')

        },
        {
            path: '/home/sms/coupon/index',
            component: () => import('@/components/Manager/sms/coupon/index.vue')
        },
        {
            path: '/home/sms/coupon/addCoupon',
            component: () => import('@/components/Manager/sms/coupon/addCoupon.vue')
        },
        {
            path: '/home/sms/coupon/edit/:id',
            component: () => import('@/components/Manager/sms/coupon/updateCoupon.vue')
        },
        ]
    },
    {
        path: '/register',
        component: () => import('@/components/register.vue'),
    },
]

const router = new VueRouter({
    routes
})

// import { GetToken } from '@/utils/auth'
// import axios from 'axios'
// router.beforeEach((to, from, next) => {
//     const token = GetToken()
//     console.log(token);

//     if (to.path.startsWith('/')) {
//         next()
//     } else {
//         axios({
//             url: '/admin/employee/checkToken',
//             method: 'get',
//             headers: {
//                 token: GetToken()
//             }
//         }).then((response) => {
//             if (response.data) {
//                 console.log('校验成功');
//                 next()
//             } else {
//                 alert('token失效重新登陆')
//                 next({ path: '/Login' });
//             }
//         })
//     }
// })

export default router